NFS Server
2011/05/27 |
Configure NFS Server to share any directories on your Network.
|
|
[1] | It's the Configuration on the system you want to build NFS server. |
[root@master ~]#
yum -y install nfs-utils
[root@master ~]#
vi /etc/idmapd.conf # line 5: uncomment and change to your domain name Domain = srv.world
[root@master ~]#
vi /etc/exports # write like below *note /home 10.0.0.0/24(rw,sync,no_root_squash,no_all_squash)
# *note /home ⇒ shared directory 10.0.0.0/24 ⇒ range of networks NFS permits accesses rw ⇒ writable sync ⇒ synchronize no_root_squash ⇒ enable root privilege no_all_squash ⇒ enable users' authority
/etc/rc.d/init.d/rpcbind start Starting rpcbind (via systemctl): Starting rpcbind: [ OK ] [ OK ] [root@master ~]# /etc/rc.d/init.d/nfslock start Starting nfslock (via systemctl): Starting NFS statd: [ OK ] [ OK ] [root@master ~]# /etc/rc.d/init.d/nfs start Starting nfslock (via systemctl): Starting NFS statd: [ OK ] Starting nfs (via systemctl): Starting rpcsvcgssd (via systemctl): [ OK ] [ 588.419461] RPC: Registered udp transport module. [ 588.419804] RPC: Registered tcp transport module. [ 588.420145] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 588.457779] Installing knfsd (copyright (C) 1996 okir@monad.swb.de). Starting NFS services: [ OK ] Starting NFS daemon: [ 588.758896] NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory [ 588.759539] NFSD: starting 90-second grace period [ OK ] Starting NFS mountd: [ OK ] Starting RPC idmapd: [ OK ] [ OK ] [root@master ~]# chkconfig rpcbind on [root@master ~]# chkconfig nfslock on [root@master ~]# chkconfig nfs on |
[2] | Configuration on NFS clients |
[root@www ~]#
yum -y install nfs-utils
[root@master ~]#
vi /etc/idmapd.conf # line 5: uncomment and change to your domain name Domain = srv.world
/etc/rc.d/init.d/rpcbind start Starting rpcbind (via systemctl): Starting rpcbind: [ OK ] [ OK ] [root@www ~]# /etc/rc.d/init.d/rpcidmapd start Starting rpcidmapd (via systemctl): Starting RPC idmapd: [ 957.433428] RPC: Registered udp transport module. [ 957.433770] RPC: Registered tcp transport module. [ 957.434115] RPC: Registered tcp NFSv4.1 backchannel transport module. [ OK ] [ OK ] [root@www ~]# /etc/rc.d/init.d/nfslock start Starting nfslock (via systemctl): Starting NFS statd: [ OK ] [ OK ] [root@www ~]# /etc/rc.d/init.d/netfs start Starting netfs (via systemctl): Mounting other filesystems: mount: sysfs already mounted or /sys busy mount: according to mtab, /sys is already mounted on /sys [FAILED] # no ploblem [ OK ] [root@www ~]# chkconfig rpcbind on [root@www ~]# chkconfig rpcidmapd on [root@www ~]# chkconfig nfslock on [root@www ~]# chkconfig netfs on [root@www ~]# mount -t nfs master.srv.world:/home /home [root@www ~]# df -h
Filesystem
Size Used Avail Use% Mounted on rootfs 28G 824M 25G 4% / rootfs 492M 0 492M 0% /dev tmpfs 500M 0 500M 0% /dev/shm tmpfs 500M 260K 500M 1% /run /dev/mapper/VolGroup-lv_root 18G 864M 16G 6% / tmpfs 500M 0 500M 0% /sys/fs/cgroup tmpfs 500M 0 500M 1% /media /dev/vda1 485M 47M 413M 11% /boot master.srv.world:/home 18G 864M 16G 6% /home # home directory on NFS is mounted
[root@www ~]#
vi /etc/fstab # add at the lat line: change home directory this server mounts to the one on NFS /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1 UUID=2078630e-e84a-49e7-af68-55f0bde8d6c3 /boot ext4 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 master.srv.world:/home
/home nfs defaults 0 0 |